<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GoIM | 注册</title>
    <link href="/static/other/css/bootstrap.css" rel="stylesheet">
    <link href="/static/other/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="/static/other/css/iCheck/custom.css" rel="stylesheet">
    <link href="/static/other/css/animate.css" rel="stylesheet">
    <link href="/static/other/css/style.css" rel="stylesheet">

</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen   animated fadeInDown">
    <div>
        <h3>欢迎注册使用GoIM！</h3>
        <p>Register in. To see it in action.</p>
        <form class="m-t" role="form">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" required="" name="username">
            </div>
            <div class="form-group">
                <input type="email" class="form-control" placeholder="用户邮箱" required="" name="email">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" required="" name="password">
            </div>
            <button type="button" class="btn btn-primary block full-width m-b" id="submit">注册</button>

            <p class="text-muted text-center">
                <small>已有账户?</small>
            </p>
            <a class="btn btn-sm btn-white btn-block" href="login.html">登陆</a>
        </form>
        <p class="m-t">
            <small>© 2018 GoIM. All Rights Reserved</small>
        </p>
    </div>
</div>

<!-- Mainly scripts -->
<script src="/static/other/js/jquery-3.1.1.min.js"></script>
<script src="/static/other/js/popper.min.js"></script>
<script src="/static/other/js/bootstrap.js"></script>
<!-- iCheck -->
<script src="/static/other/js/iCheck/icheck.min.js"></script>
<!-- layer -->
<script src="/static/layer/layer.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });

    function wait(timeout) {
        if (timeout === 0) {
            window.location.href = "/";
        } else {
            setTimeout("wait(0)", 1000);
        }
    }

    $("#submit").click(function () {
        $(document).ready(function () {
            const postData = $("form").serialize();
            $.post("/register", postData, function (res) {
                if (res.Error === 0) {
                    layer.msg("注册成功", {time: 2000});
                    wait(1);
                } else {
                    layer.msg(res.Title + res.Msg, {
                        icon: 2,
                        shade: [0.8, '#393D49'], // 透明度  颜色
                        time: 2000
                    });
                }
            }, "json");
            return false;
        });
    });
</script>
</body>

</html>
